DECLARE @Id Int                               
Select @Id = Id From sysobjects Where Name = 'IHIOPrescriptionDetail'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'NumberOfPeriodCode')
  Alter Table IHIOPrescriptionDetail Add NumberOfPeriodCode VARCHAR(20);

                       
DECLARE @ConstraintName VARCHAR(MAX)
SELECT @ConstraintName = obj_Constraint.NAME
FROM   sys.objects obj_table 
    JOIN sys.objects obj_Constraint 
        ON obj_table.object_id = obj_Constraint.parent_object_id 
    JOIN sys.sysconstraints constraints 
            ON constraints.constid = obj_Constraint.object_id 
    JOIN sys.columns columns 
            ON columns.object_id = obj_table.object_id 
        AND columns.column_id = constraints.colid 
WHERE obj_table.NAME='IHIOPrescriptionDetail' AND columns.NAME = 'NumberOfPeriod'
IF @ConstraintName IS NOT NULL
BEGIN 
  SET @ConstraintName = 'ALTER TABLE IHIOPrescriptionDetail DROP CONSTRAINT ' + @ConstraintName 
  EXEC(@ConstraintName)
  ALTER TABLE IHIOPrescriptionDetail ALTER COLUMN NumberOfPeriod FLOAT 
  ALTER TABLE dbo.IHIOPrescriptionDetail ADD CONSTRAINT DF_IHIOPresc_NumberOfPeriod DEFAULT(0) FOR NumberOfPeriod
END 

ALTER TABLE dbo.IHIOPrescription ALTER COLUMN DoctorName NVARCHAR(max)
ALTER TABLE dbo.IHIOPrescription ALTER COLUMN DoctorLastName NVARCHAR(max)